<template>
  <div class="error-page">
    <div class="error-content">
      <van-empty
        :image="errorImage"
        :description="errorMessage || '页面访问错误'"
      />
      <!-- <van-button
        round
        type="success"
        block
        @click="goLogin"
        v-if="from && isWeChatBrowser"
        >去登录</van-button
      > -->
      <van-button round type="primary" block @click="goBack"
        >返回上一页</van-button
      >
    </div>
  </div>
</template>

<script setup>
import { computed, ref } from "vue";
import { useRoute, useRouter } from "vue-router";
import { useAuthStore } from "@/store/useAuthStore";
import { isWeChatBrowserPro } from "@/utils/wechat";
const { handleAuth } = useAuthStore();

const route = useRoute();
const router = useRouter();

const errorData = computed(() => route.params.errorData);
const from = computed(() => route.params.from);
const errorMessage = computed(() => route.query.message);
const errorImage = computed(() => "error");

const goBack = () => {
  router.back();
};
const isWeChatBrowser = isWeChatBrowserPro();
const goLogin = () => {
  from.value && handleAuth(from.value);
};
</script>

<style scoped>
.error-page {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f7f8fa;
}

.error-content {
  width: 80%;
  padding: 20px;
}

.van-button {
  margin-top: 24px;
}
</style>
